// Author: Klay Thompson
// Problem: P5998 [PA2014] Plemiona
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T>inline void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T>inline void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

const int maxn = 500010;

struct node {
  int lx, rx, ly, ry;
  friend node operator+(node x, node y) {
    node res;
    res.lx = min(x.lx, y.lx), res.rx = max(x.rx, y.rx);
    res.ly = min(x.ly, y.ly), res.ry = max(x.ry, y.ry);
    return res;
  }
} a[maxn];

int n, cn, cm, cx[maxn], cy[maxn], fa[maxn], vis[maxn], ok;
vector<int> s1[maxn << 2], s2[maxn << 2];

int find(int x) {
  return fa[x] == x ? x : fa[x] = find(fa[x]);
}

#define mid ((l + r) >> 1)

void upd(int c, int l, int r, int x, int y, int id) {
  s1[c].emplace_back(id);
  if (l == x && r == y) return s2[c].emplace_back(id), void();
  if (y <= mid) upd(c << 1, l, mid, x, y, id);
  else if (x > mid) upd(c << 1 | 1, mid + 1, r, x, y, id);
  else upd(c << 1, l, mid, x, mid, id), upd(c << 1 | 1, mid + 1, r, mid + 1, y, id);
}

void qry(int c, int l, int r, int x, int y, int id, int d) {
  while (!s2[c].empty()) {
    int w = s2[c].back();
    if (a[w].ry < a[id].ly - d) break;
    s2[c].pop_back();
    if (vis[w]) continue;
    a[id] = a[id] + a[w], vis[w] = 1;
    fa[find(w)] = find(id), ok = 1;
  }
  if (l == x && r == y) {
    while (!s1[c].empty()) {
      int w = s1[c].back();
      if (a[w].ry < a[id].ly - d) break;
      s1[c].pop_back();
      if (vis[w]) continue;
      a[id] = a[id] + a[w], vis[w] = 1;
      fa[find(w)] = find(id), ok = 1;
    }
    return;
  }
  if (y <= mid) qry(c << 1, l, mid, x, y, id, d);
  else if (x > mid) qry(c << 1 | 1, mid + 1, r, x, y, id, d);
  else qry(c << 1, l, mid, x, mid, id, d), qry(c << 1 | 1, mid + 1, r, mid + 1, y, id, d);
}

#undef mid

int main() {
  freopen("grid.in", "r", stdin);
  freopen("grid.out", "w", stdout);
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  cin >> cn >> cm >> n;
  rep (i, 1, n) cin >> a[i].lx >> a[i].ly, a[i].rx = a[i].lx, a[i].ry = a[i].ly;
  sort(a + 1, a + n + 1, [&](node x, node y) { return x.ry == y.ry ? x.ly < y.ly : x.ry < y.ry; });
  rep (i, 1, n) fa[i] = i;
  rep (i, 1, n) {
    do {
      ok = 0;
      int L = a[i].lx, R = a[i].rx;
      qry(1, 1, cn, L, R, i, 2);
      qry(1, 1, cn, max(1, L - 1), min(cn, R + 1), i, 1);
      qry(1, 1, cn, max(1, L - 2), min(cn, R + 2), i, 0);
    } while (ok);
    upd(1, 1, cn, a[i].lx, a[i].rx, i);
  }
  ll ans = 0;
  rep (i, 1, n) if (find(i) == i) ans += 1ll * (a[i].rx - a[i].lx + 1) * (a[i].ry - a[i].ly + 1);
  cout << ans << '\n';
}